using UnityEngine;
using System.Collections;

public class EnemyTakeDamageState : State<EnemyControl>
{
    #region Singleton

    private static EnemyTakeDamageState instance = new EnemyTakeDamageState();
    public static EnemyTakeDamageState Instance { get { return instance; } }
    private EnemyTakeDamageState() { }

    #endregion

    #region State

    public override void OnEnterState(EnemyControl behaviour)
    {
        behaviour.isTakeDamageEnable = false;
        behaviour.waitTimeEndState = Time.timeSinceLevelLoad + behaviour.waitTimeTakeDamage;
    }

    public override void OnUpdateState(EnemyControl behaviour)
    {
        if (behaviour.waitTimeEndState <= Time.timeSinceLevelLoad)
        {
            if (behaviour.health > 0)
                behaviour.State = EnemyAlertState.Instance;
            else
                behaviour.State = EnemyDieState.Instance;

        }
    }

    public override void OnFixedUpdateState(EnemyControl behaviour)
    {
    }

    public override void OnExitState(EnemyControl behaviour)
    {
        behaviour.isTakeDamageEnable = true;
    }

    public override void OnCollisionState(EnemyControl behaviour, Collision other)
    {
    }

    public override void OnTriggerState(EnemyControl behaviour, Collider other)
    {
    }

    #endregion
}